package com.goldcontrol.cloudweb.controller;

import com.goldcontrol.cloudweb.model.JobEntity;
import com.goldcontrol.cloudweb.service.ScheduledService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/qt")
public class QuartzController {

    @Resource
    private ScheduledService scheduledService;

    @RequestMapping("/add")
    public void addJob() {
        try {
            JobEntity jobEntity = new JobEntity();
            jobEntity.setProjectId(1);
            jobEntity.setState(1);
            jobEntity.setCronTime("0/10 * * * * ?");
            scheduledService.addQuartzJob(jobEntity);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/update")
    public void updateJob() {
        try {
            JobEntity jobEntity = new JobEntity();
            jobEntity.setProjectId(1);
            jobEntity.setState(1);
            jobEntity.setCronTime("0/5 * * * * ?");
            scheduledService.updateQuartzJob(jobEntity);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//
//    @RequestMapping("/delete")
//    public void delete() {
//        try {
//            JobEntity jobEntity = new JobEntity();
//            jobEntity.setDevid("1");
//            jobEntity.setItemid("1");
//            jobEntity.setVal("1");
//            jobEntity.setCronTime("0/10 * * * * ?");
//            scheduledService.removeJob(jobEntity);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }


}
